package com.czl.module_user.viewmodel

import androidx.databinding.ObservableField
import com.czl.base.base.BaseBean
import com.czl.base.base.BaseViewModel
import com.czl.base.base.MyApplication
import com.czl.base.binding.command.BindingAction
import com.czl.base.binding.command.BindingCommand
import com.czl.base.config.AppConstants
import com.czl.base.data.DataRepository
import com.czl.base.data.bean.IntegralBean
import com.czl.base.data.bean.PeopleManagerBean
import com.czl.base.extension.ApiSubscriberHelper
import com.czl.base.util.RxThreadHelper

/**
 *
 * @Description:
 * @Author: XCH
 * @CreateDate: 2022/2/8 11:20
 */
class IntegralDetailViewModel(application: MyApplication, model: DataRepository) :
    BaseViewModel<DataRepository>(application, model) {

    val point = ObservableField("0")

    val onScoreClick: BindingCommand<Any> = BindingCommand(BindingAction {
        startContainerActivity(AppConstants.Router.User.F_INTEGRAL_LIST)
    })

    fun getPointDetail() {
        model.getPointDetail(
            model.getAreaId()
        )
            .compose(RxThreadHelper.rxSchedulerHelper(this))
            .subscribe(object : ApiSubscriberHelper<BaseBean<String>>() {
                override fun onResult(t: BaseBean<String>) {
                    if (t.code == 200) {
                        point.set(t.data)
                    } else {
                        showErrorToast(t.msg)
                    }
                }

                override fun onFailed(msg: String?) {
                    showErrorToast(msg)
                }

            })
    }
}